import greenfoot.*;  

public class RulesWorld extends World {
    public RulesWorld() {    
        super(400, 300, 1); 
        showRules();
        addObject(new BackButton(), 200, 250); // 添加返回按钮
    }

    private void showRules() {
        GreenfootImage rulesImage = new GreenfootImage(400, 300);
        GreenfootImage backgroundImage = new GreenfootImage("background2.png");
        
        rulesImage.setColor(Color.BLACK);
        backgroundImage.setFont(new Font("SimSun", false, false, 24)); // 使用支持中文的字体
        backgroundImage.drawString("游戏规则：", 40, 40);
        backgroundImage.drawString("1. 点击方块以打开它们。", 40, 80);
        backgroundImage.drawString("2. 点击右键标记地雷。", 40, 120);
        backgroundImage.drawString("3. 如果打开地雷，游戏结束。", 40, 160);
        backgroundImage.drawString("4. 打开所有非地雷方块以胜利。", 40, 200);
        
        setBackground(backgroundImage); // 显示规则
    }
}
